<script>
	import {
		faceAuthNotice
	} from '@/api/authentication'
	export default {
		onLaunch() {
			this.checkVserion();
		},
		onShow(options) {
			// console.log('app.vue', options);
			// if (typeof options.referrerInfo.extraData != 'undefined') {
			// 	if (options.scene === 1038 && options.referrerInfo.extraData && options.referrerInfo.extraData.faceResult) {
			// 		uni.reLaunch({
			// 			url: `/pagesA/my/order/myorder/myorder?active=0&id=0`
			// 		})
			// 	}else if(options.referrerInfo.extraData.callbackObj.from == 'notarization'){
			// 			uni.reLaunch({
			// 				url:'/pagesB/eleSign/eleSign?orderId='+options.referrerInfo.extraData.callbackObj.orderId
			// 			})
			// 		}
			// }
			if (typeof options.referrerInfo.extraData != 'undefined') {
				if (options.referrerInfo.extraData.callbackObj.from == 'esign') {
					//如果需要进行跳转的话，可以在这边处理，跳转到自己的小程序某个页面
					const isSuccess = options.referrerInfo ? options.referrerInfo.extraData.isSuccess : ''
					uni.setStorageSync('isSuccess', isSuccess)
					let data = {
						flowId: options.referrerInfo.extraData.callbackObj.flowId,
						status: options.referrerInfo.extraData.isSuccess,
						user_id: options.referrerInfo.extraData.callbackObj.userId
					}
					faceAuthNotice(data).then(res => {

					})
					uni.reLaunch({
						url: `/pagesA/my/order/myorder/orderDetail?order_id=${ options.referrerInfo.extraData.callbackObj.orderId }`
					})
				}else if(options.referrerInfo.extraData.callbackObj.from == 'notarization'){
					uni.reLaunch({
						url:'/pagesB/eleSign/eleSign?orderId='+options.referrerInfo.extraData.callbackObj.orderId
					})
				}
			}
		},
		mounted() {
			this.getMenuData();
		},
		methods: {
			checkVserion() {
				const updateManager = uni.getUpdateManager();
				updateManager.onCheckForUpdate(function(res) {
					// 请求完新版本信息的回调
					console.log(res.hasUpdate)
				})

				updateManager.onUpdateReady(function() {
					uni.showModal({
						title: '更新提示',
						content: '新版本已经准备好，是否重启应用？',
						success: function(res) {
							if (res.confirm) {
								// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
								updateManager.applyUpdate()
							}
						}
					})
				})
			},
			getMenuData() {
				const menuInfo = uni.getMenuButtonBoundingClientRect();
				uni.setStorageSync("menuTop", menuInfo.top)
			}
		},
		globalData: {
			baseImgUrl: 'https://img.tingxiangzu.com/test220914/', //首页图片请求头
			baseImg: 'https://img.tingxiangzu.com/', //其他页面图片请求头
			isIphoneXSeries: false,
			token: uni.getStorageSync('token') || '', // 获取token
			userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}'), //用户信息
			tel: uni.getStorageSync('tel') || '', // 用户手机号
			openId: '',
			city: uni.getStorageSync('city') || '全国',
			member_id: null, // 测试用的会员id，会删
			unique_code: [],
			sence: ''
		},
	}
</script>

<style lang="scss">
	@import 'wxcomponents/vant-weapp/common/index.wxss';
	/*每个页面公共css */
	@import '@/uni_modules/uni-scss/index.scss';

	.example-info {
		font-size: 14px;
		color: #333;
		padding: 10px;
	}

	page {
		background-color: #f5f5f5;
	}

	.b {
		margin-bottom: 15rpx;
	}

	::-webkit-scrollbar {
		display: none;
		width: 0;
		height: 0;
		color: transparent;
	}

	.flex {
		display: flex;
	}

	.flex-center {
		align-items: center;
		justify-content: center
	}

	.justify-between {
		justify-content: space-between
	}

	.align-center {
		align-items: center;
	}
</style>